package com.jwt.controller;

import com.jwt.pojo.ResponseResult;
import com.jwt.pojo.User;
import com.jwt.service.UserService;
import java.util.List;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
	@Resource
	UserService userService;
	@PreAuthorize("hasAnyRole('manager,admin')")
	@GetMapping("/users")
	public ResponseResult<?> findAllUsers(){
		ResponseResult<List<User>> result=new ResponseResult<>();
		result.setCode(200);
		result.setFlag(true);
		result.setMsg("查询成功");
		result.setData(userService.findAllUsers());
		return result;
	}
}
